from PyQt5 import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui

import sys

class QCalendarTest(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(QCalendarTest, self).__init__(parent)

        self.setWindowTitle("QCalendarTest例子")

        self.initUI()

    def initUI(self):
        self.cal = QtWidgets.QCalendarWidget(self)
        self.cal.setMinimumDate(QtCore.QDate(1980, 1, 1))
        self.cal.setMaximumDate(QtCore.QDate(3000, 1, 1))
        self.cal.setGridVisible(True)

        self.cal.move(20, 20)
        self.cal.clicked[QtCore.QDate].connect(self.show_date)

        self.label = QtWidgets.QLabel(self)
        date = self.cal.selectedDate()
        self.label.setText(date.toString("yyyy-MM-dd dddd"))
        self.label.move(20, 300)

        self.setGeometry(100, 100, 400, 350)

    def show_date(self, date):
        self.label.setText(date.toString("yyyy-MM-dd dddd"))

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    QtWidgets.QApplication.setStyle("Fusion")
    win = QCalendarTest()
    win.show()
    sys.exit(app.exec_())